﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bus.Model;
using Bus.Bll;

public partial class admin_top : System.Web.UI.Page
{
    private tb_user admUser = new tb_user ();
    private tb_custom cusUser = new tb_custom ();
    private UserModel user = null;
    private CustomModel custM = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitLoginInfo();
        }

    }
    private void InitLoginInfo()
    {
        HttpCookie hc = Request.Cookies.Get("bus_ck_info");
        string vl = hc.Value.Trim();
        string[] valuesInfo = vl.Split('&');
      
        if (valuesInfo[0].Split ('=')[1] == "0")
        {
            user = new UserModel();
            user = admUser.GetModel(int.Parse(valuesInfo[1].Split ('=')[1]));
            //Session["userid"] = user.uid;
            //Session["utp"] = 0;
            if (user.usertype == 0)
                utpinfo.Text = "经理/管理员";
            if (user.usertype == 1)
                utpinfo.Text = "业务员";
            if (user.usertype == 2)
                utpinfo.Text = "出纳员";
            name.Text = user.username.Trim();
        }
        else
        {
            custM = new CustomModel();
            custM = cusUser.GetModel(int.Parse(valuesInfo[1].Split ('=')[1]));
            //Session["userid"] = custM.cid;
            //Session["utp"] = 1;
            name.Text = custM.cname.Trim();
            utpinfo.Text = "乘客";

        }

    
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //清除当前登录的用户及类型
        Session["userid"] = null;
        Session["utp"] = null;
        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>top.location.href='../Default.aspx';</script>");
        
    }
}
